using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Reflection;
using System.Security.Permissions;

namespace Adge.DALFactory
{
    //[PrincipalPermission(SecurityAction.Demand, Authenticated = true)]
    public sealed class DataAccess<T>
    {
        // Look up the DAL implementation we should be using
        private static readonly string path = ConfigurationManager.AppSettings["WebDAL"];
        
        public static Adge.IDAL.IAdgeArBase<T> CreateEntity()
        {
            string className = path + ".AdgeArBase`1";
            Type generic = Assembly.Load(path).GetType(className);
            Type[] typeArgs = { typeof(T) };
            Type constructed = generic.MakeGenericType(typeArgs);
            return (Adge.IDAL.IAdgeArBase<T>)Activator.CreateInstance(constructed); 
        } 
    }
}
